/** 
 * DAOException.java
 * 
 * 1.0
 * 
 * 04/07/2014
 * 
 * Copyright (c) 2013 FPT Software.
 * FPT Building, Street No1, DaNang Industrial Zone, AnDon, 
 * AnHaiBac Ward, SonTra District, DaNang City.
 * All rights reserved.
 */
package com.jms.fu.model.bo;

import java.util.ArrayList;
import java.util.List;

import com.jms.fu.exception.DAOException;
import com.jms.fu.model.bean.AppDownloaded;
import com.jms.fu.model.bean.User;
import com.jms.fu.model.dao.UserDAO;

/**
 * Class to implement business logic of module User
 * 
 * @author Design Framework Group
 */

public class UserBO {
	UserDAO userDAO = null;

	/**
	 * Method to check Login
	 * 
	 * @param username
	 *            ,password
	 * @return an int indicates user role in system 0:admin, 1:loptruong,
	 *         2:hocvien if username and password is valid, return -1 when login
	 *         failed
	 * @throws DAOException
	 */
	public int checkLogin(String username, String password) throws DAOException {
		userDAO = new UserDAO();
		return userDAO.checkLogin(username, password);
	}

	/**
	 * Method to check status of username
	 * 
	 * @param account
	 * 
	 * @return if status form table tb_Class is 1 return 1 and return 0 when
	 *         status is 0
	 * 
	 * @throws DAOException
	 */
	public int checkStatus(String username) throws DAOException {
		userDAO = new UserDAO();
		return userDAO.checkStatus(username);
	}

	public boolean checkUsername(String username) throws DAOException {
		userDAO = new UserDAO();
		return userDAO.checkUsername(username);
	}

	public void addNewUser(String username, String password, String name,
			String email) throws DAOException {
		userDAO = new UserDAO();
		userDAO.addNewUser(username, password, name, email);

	}

	public void changePassword(String username, String password)
			throws DAOException {
		userDAO = new UserDAO();
		userDAO.changePassword(username, password);

	}

	public boolean checkPassword(String username, String password)
			throws DAOException {
		userDAO = new UserDAO();
		return userDAO.checkPassword(username, password);
	}

	public User getUserInfoByUsername(String username) throws DAOException {
		userDAO = new UserDAO();
		return userDAO.getUserInfoByUsername(username);
	}

	public void updateMemberInfo(String username, String name, String email)
			throws DAOException {
		userDAO = new UserDAO();
		userDAO.updateMemberInfo(username, name, email);

	}

	public void updateDevInfo(String username, String name, String email,
			String bankAccountNo, String bankAccountName, String bankName,String paypal)
			throws DAOException {
		userDAO = new UserDAO();
		userDAO.updateDevInfo(username, name, email, bankAccountNo,
				bankAccountName, bankName,paypal);

	}

	public void goDev(String username, String bankAccountNo,
			String bankAccountName, String bankName,float balance,String paypal) throws DAOException {
		userDAO = new UserDAO();
		userDAO.goDev(username,bankAccountNo,bankAccountName,bankName,balance,paypal);
		
	}

	public ArrayList<User> getAllUser() throws DAOException {
		userDAO = new UserDAO();
		return userDAO.getAllUser();
	}

	public void blockUser(String username) throws DAOException {
		userDAO = new UserDAO();
		 userDAO.blockUser(username);
		
	}

	public void unblockUser(String username) throws DAOException {
		userDAO = new UserDAO();
		 userDAO.unblockUser(username);
		
	}

	public void deleteUser(String username) throws DAOException {
		userDAO = new UserDAO();
		 userDAO.deleteUser(username);
		
	}

	public void deposit(String username, float newBalance) throws DAOException {
		userDAO = new UserDAO();
		 userDAO.deposit(username,newBalance);
		
	}

//	public List<AppDownloaded> getListAppDown(String username) throws DAOException {
//		userDAO = new UserDAO();
//		return userDAO.getListAppDown(username);
//	}

}
